import Vue from 'vue'
import VueRouter from 'vue-router'
// import Vuex from 'vuex'

// 登录页面
import login from '../components/Login/login.vue'
import nav from '../components/Login/nav.vue'
import register from '../components/Login/register.vue'
import recoverpw from '../components/Login/recoverpw.vue'

// 主页||控制台
import homePage from '../components/HomePage/homePage.vue'

// 大数据
import bigData from '../components/BigData/bigData.vue'

//脚标机监控页面
import barcodeMachineStatus from '../components/BarcodeMachine/barcodeMachineStatus.vue'
import barcodeMachineAlert from '../components/BarcodeMachine/barcodeMachineAlert.vue'

//贴标信息管理
import labelingRecordList from '../components/LabelingRecord/labelingRecordList.vue'
import barcodeMachineSearch from '../components/LabelingRecord/barcodeMachineSearch.vue'

// 基础数据管理
import slaughterHouseManage from '../components/BasicInformationManage/slaughterHouseManage.vue'
import toMarketManage from '../components/BasicInformationManage/toMarketManage.vue'
import stallsManage from '../components/BasicInformationManage/stallsManage.vue'
import allBarcodeMachineManage from '../components/BasicInformationManage/allBarcodeMachineManage.vue'
import barcodeMachineManage from '../components/BasicInformationManage/barcodeMachineManage.vue'
import idCardManage from '../components/BasicInformationManage/idCardManage.vue'
import poultryCategoryManage from '../components/BasicInformationManage/poultryCategoryManage.vue'
import poultryParentManage from '../components/BasicInformationManage/poultryParentManage.vue'
import entrustManage from '../components/BasicInformationManage/entrustManage.vue'

// 条形码发放与回收管理
import barcodeGrantList from '../components/BarcodeDistributionAndRecyclingManagement/barcodeGrantList.vue'
import barcodeRecoveryList from '../components/BarcodeDistributionAndRecyclingManagement/barcodeRecoveryList.vue'

// 脚标机发放与回收管理
import barcodeMachineGrant from '../components/BarcodeMachineGrantAndRecovery/barcodeMachineGrant.vue'
import barcodeMachineRecovery from '../components/BarcodeMachineGrantAndRecovery/barcodeMachineRecovery.vue'

// 脚标机维修报废管理
import barcodeMachineRepair from '../components/BarcodeMachineRepairAndScrap/barcodeMachineRepair.vue'
import barcodeMachineScrap from '../components/BarcodeMachineRepairAndScrap/barcodeMachineScrap.vue'

// ID卡发放回收管理
import idCardGrant from '../components/IdCardGrantAndRecovery/idCardGrant.vue'
import idCardRecovery from '../components/IdCardGrantAndRecovery/idCardRecovery.vue'

// 管理员审核
import slaughterHouseStallsAdmin from '../components/AdministratorAudit/slaughterHouseStallsAdmin.vue'
import toStallsAdmin from '../components/AdministratorAudit/toStallsAdmin.vue'
import slaughterHouseAdmin from '../components/AdministratorAudit/slaughterHouseAdmin.vue'

// 用户管理
import userInformationManage from '../components/UserManage/userInformationManage.vue'
import userRolesManage from '../components/UserManage/userRolesManage.vue'

// 角色权限管理
import roleMenu from '../components/RoleMenu/roleMenu.vue'

// 维修人员管理
import maintenancePersonnelList from '../components/MaintenancePersonnelList/maintenancePersonnelList.vue'

// 日志信息管理
import logRecordList from '../components/LogRecordList/logRecordList.vue'

Vue.use(VueRouter)


const routes = [
    // 登录
    {
        path: '/',
        redirect: '/login'
    },
    {
        path: '/login',
        component: login
    },
    // 注册页
    {
        path: '/register',
        component: register
    },
    // 忘记密码
    {
        path: '/recoverpw',
        component: recoverpw
    },
    // 侧边栏
    {
        path: '/nav',
        component: nav,
        redirect: '/homePage',
        children: [{
                path: '/homePage',
                component: homePage,
            },
            // 脚标机监控
            {
                path: '/barcodeMachineStatus',
                component: barcodeMachineStatus
            }, {
                path: '/barcodeMachineAlert',
                component: barcodeMachineAlert
            },
            // 贴标信息管理
            {
                path: '/labelingRecordList',
                component: labelingRecordList
            }, {
                path: '/barcodeMachineSearch',
                component: barcodeMachineSearch
            },
            // 基础数据管理
            {
                path: '/slaughterHouseManage',
                component: slaughterHouseManage
            }, {
                path: '/toMarketManage',
                component: toMarketManage
            }, {
                path: '/stallsManage',
                component: stallsManage
            }, {
                path: '/allBarcodeMachineManage',
                component: allBarcodeMachineManage
            }, {
                path: '/barcodeMachineManage',
                component: barcodeMachineManage
            }, {
                path: '/idCardManage',
                component: idCardManage
            }, {
                path: '/poultryCategoryManage',
                component: poultryCategoryManage
            }, {
                path: '/poultryParentManage',
                component: poultryParentManage
            }, {
                path: '/entrustManage',
                component: entrustManage
            },
            // 条形码发放回收
            {
                path: '/barcodeGrantList',
                component: barcodeGrantList,
            }, {
                path: '/barcodeRecoveryList',
                component: barcodeRecoveryList,
            },
            // 脚标机发放回收
            {
                path: '/barcodeMachineGrant',
                component: barcodeMachineGrant,
            }, {
                path: '/barcodeMachineRecovery',
                component: barcodeMachineRecovery,
            },
            // 脚标机报修报废
            {
                path: '/barcodeMachineRepair',
                component: barcodeMachineRepair,
            }, {
                path: '/barcodeMachineScrap',
                component: barcodeMachineScrap,
            },
            // ID卡发放回收
            {
                path: '/idCardGrant',
                component: idCardGrant,
            }, {
                path: '/idCardRecovery',
                component: idCardRecovery,
            },
            // 管理员审核
            {
                path: '/slaughterHouseStallsAdmin',
                component: slaughterHouseStallsAdmin,
            }, {
                path: '/toStallsAdmin',
                component: toStallsAdmin,
            }, {
                path: '/slaughterHouseAdmin',
                component: slaughterHouseAdmin,
            },
            // 用户管理
            {
                path: '/userInformationManage',
                component: userInformationManage,
            }, {
                path: '/userRolesManage',
                component: userRolesManage,
            },
            // 角色权限管理
            {
                path: '/roleMenu',
                component: roleMenu
            },
            // 维修人员管理
            {
                path: '/maintenancePersonnelList',
                component: maintenancePersonnelList
            },
            // 日志信息管理
            {
                path: '/logRecordList',
                component: logRecordList
            }
        ],
    },
    // 大数据
    {
        path: '/bigData',
        component: bigData,
    }
]


const router = new VueRouter({
    routes
})

// 拦截路由导航守卫
router.beforeEach((to, from, next) => {
    if (to.path === '/login') return next()
    // 获取token
    const pnameStr = window.sessionStorage.getItem('pname')
    // console.log(pnameStr)
    // if(!pnameStr) return next('/login')
    next()

})
export default router